package com.cashmama.market.api.domain.service;

import com.cashmama.market.api.domain.vo.RequestLocalInfo;
import com.cashmama.market.api.infras.utils.StringUtils;
import com.fqgj.xjd.user.client.UserBehaviorService;
import com.fqgj.xjd.user.client.enums.UserEventTrackEnum;
import com.fqgj.xjd.user.client.request.UserBehaviorEvent2Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Author: Karl
 * Date: 2020/11/23 3:47 下午
 */
@Component
public class UserEventTrackService {

    @Autowired
    private UserBehaviorService userBehaviorService;

    public void e_app_register_success() {
        try {
            if (RequestLocalInfo.getCurrentUser() == null || StringUtils.isEmpty(RequestLocalInfo.getCurrentUser().getUserCode())) {
                return;
            }
            UserBehaviorEvent2Request userBehaviorEvent2Request = new UserBehaviorEvent2Request();
            userBehaviorEvent2Request.setUserCode(RequestLocalInfo.getCurrentUser().getUserCode());
            userBehaviorEvent2Request.setUserEventTrack(UserEventTrackEnum.e_app_register_success);
            userBehaviorService.addUserEventTrack(userBehaviorEvent2Request);
        } catch (Exception e) {
        }
    }

    public void e_app_login_success() {
        try {
            if (RequestLocalInfo.getCurrentUser() == null || StringUtils.isEmpty(RequestLocalInfo.getCurrentUser().getUserCode())) {
                return;
            }
            UserBehaviorEvent2Request userBehaviorEvent2Request = new UserBehaviorEvent2Request();
            userBehaviorEvent2Request.setUserCode(RequestLocalInfo.getCurrentUser().getUserCode());
            userBehaviorEvent2Request.setUserEventTrack(UserEventTrackEnum.e_app_login_success);
            userBehaviorService.addUserEventTrack(userBehaviorEvent2Request);
        } catch (Exception e) {
        }
    }

    public void e_app_open_home_page() {
        try {
            if (RequestLocalInfo.getCurrentUser() == null || StringUtils.isEmpty(RequestLocalInfo.getCurrentUser().getUserCode())) {
                return;
            }
            UserBehaviorEvent2Request userBehaviorEvent2Request = new UserBehaviorEvent2Request();
            userBehaviorEvent2Request.setUserCode(RequestLocalInfo.getCurrentUser().getUserCode());
            userBehaviorEvent2Request.setUserEventTrack(UserEventTrackEnum.e_app_open_home_page);
            userBehaviorService.addUserEventTrack(userBehaviorEvent2Request);
        } catch (Exception e) {
        }
    }


    public void e_app_idcard_done() {
        try {
            if (RequestLocalInfo.getCurrentUser() == null || StringUtils.isEmpty(RequestLocalInfo.getCurrentUser().getUserCode())) {
                return;
            }
            UserBehaviorEvent2Request userBehaviorEvent2Request = new UserBehaviorEvent2Request();
            userBehaviorEvent2Request.setUserCode(RequestLocalInfo.getCurrentUser().getUserCode());
            userBehaviorEvent2Request.setUserEventTrack(UserEventTrackEnum.e_app_idcard_done);
            userBehaviorService.addUserEventTrack(userBehaviorEvent2Request);
        } catch (Exception e) {
        }
    }


    public void e_app_submit_information_done() {
        try {
            if (RequestLocalInfo.getCurrentUser() == null || StringUtils.isEmpty(RequestLocalInfo.getCurrentUser().getUserCode())) {
                return;
            }
            UserBehaviorEvent2Request userBehaviorEvent2Request = new UserBehaviorEvent2Request();
            userBehaviorEvent2Request.setUserCode(RequestLocalInfo.getCurrentUser().getUserCode());
            userBehaviorEvent2Request.setUserEventTrack(UserEventTrackEnum.e_app_submit_information_done);
            userBehaviorService.addUserEventTrack(userBehaviorEvent2Request);
        } catch (Exception e) {
        }
    }

    public void e_app_bind_bankcard_done() {
        try {
            if (RequestLocalInfo.getCurrentUser() == null || StringUtils.isEmpty(RequestLocalInfo.getCurrentUser().getUserCode())) {
                return;
            }
            UserBehaviorEvent2Request userBehaviorEvent2Request = new UserBehaviorEvent2Request();
            userBehaviorEvent2Request.setUserCode(RequestLocalInfo.getCurrentUser().getUserCode());
            userBehaviorEvent2Request.setUserEventTrack(UserEventTrackEnum.e_app_bind_bankcard_done);
            userBehaviorService.addUserEventTrack(userBehaviorEvent2Request);
        } catch (Exception e) {
        }
    }

    public void e_app_open_create_order_page() {
        try {
            if (RequestLocalInfo.getCurrentUser() == null || StringUtils.isEmpty(RequestLocalInfo.getCurrentUser().getUserCode())) {
                return;
            }
            UserBehaviorEvent2Request userBehaviorEvent2Request = new UserBehaviorEvent2Request();
            userBehaviorEvent2Request.setUserCode(RequestLocalInfo.getCurrentUser().getUserCode());
            userBehaviorEvent2Request.setUserEventTrack(UserEventTrackEnum.e_app_open_create_order_page);
            userBehaviorService.addUserEventTrack(userBehaviorEvent2Request);
        } catch (Exception e) {
        }
    }
}
